let _goddess = null
let _heartValue = 0

cc.Class({
    extends: cc.Component,

    properties: {
        nickname: cc.Label, 
        age: cc.Label, 
        txt: cc.Label, 
        giftEditBox: cc.EditBox, 
        heartValue: cc.Label, 
    }, 

    onLoad () {
        _goddess = jsb.Goddess.getInstance()

        _heartValue = 0
        this.heartValue.string = _heartValue
    }, 

    start () {
        _goddess.nickname = 'Honey'          // Goddess.setName()
        this.nickname.string = _goddess.nickname        // Goddess.getName()

        _goddess.age = 20           // Goddess.setAge()
        this.age.string = _goddess.age      // Goddess.getAge()
    }, 
    
    sayHi() {
        this.txt.string = _goddess.sayHi()
    }, 

    sendGift () {
        let gift_name = this.giftEditBox.string
        let gift = new jsb.Gift(gift_name)

        _goddess.receiveGift(gift, (msg, val) => {
            this.txt.string = msg + '(' + val + ')'
            
            _heartValue += val
            this.heartValue.string = _heartValue
        })
    }, 
});
